package com.gjp.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.gjp.myapplication.adapter.PhotoAdapter;
import com.gjp.myapplication.bean.ImageItem;

import java.util.Arrays;

public class PhotoListActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.photo_list);
        setTitle("系列");
        init();
    }

    private void init() {

        final ImageItem[] urls = new ImageItem[]{
                new ImageItem("https://bkimg.cdn.bcebos.com/pic/4ec2d5628535e5dde71164990d8fb0efce1b9d16c469?x-bce-process=image/watermark,image_d2F0ZXIvYmFpa2UxODA=,g_7,xp_5,yp_5", "琴"),
                new ImageItem("https://img.sxsme.com.cn/uploadimg/image/20200928/20200928110419_20371.jpg", "魈"),
                new ImageItem("https://pics7.baidu.com/feed/dcc451da81cb39db1cb1e6832d7b7623aa183063.png?token=94ddb16dfc792965f7e09d92527bd3d6", "刻晴"),
                new ImageItem("https://pics1.baidu.com/feed/aa64034f78f0f736e48a485df638cc1eeac413ee.png?token=0dd563a3e752f96704ae0a57b12e6963", "凝光"),
                new ImageItem("https://pics1.baidu.com/feed/adaf2edda3cc7cd9be78ca5bc56c5e38b90e9154.png?token=90aa32ce226f070581e41465da323750", "新角色")
        };

        PhotoAdapter adapter = new PhotoAdapter(Arrays.asList(urls));
        RecyclerView recyclerView = findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new GridLayoutManager(PhotoListActivity.this, 2));

        recyclerView.setAdapter(adapter);

        adapter.setOnItemClickListener(new PhotoAdapter.OnItemClickListener() {
            @Override
            public void onClick(View v, int position) {
                // 点击跳转到相册页面
                Intent intent = new Intent(PhotoListActivity.this, PhotoList2Activity.class);
                intent.putExtra("data", urls);
                startActivity(intent);
                //图片查看器
                // data 可以多张图片List或单张图片，支持的类型可以是{@link Uri}, {@code url}, {@code path},{@link File}, {@link DrawableRes resId}…等
//                ImageViewer.load(listData)//要加载的图片数据，单张或多张
//                        .selection(position)//当前选中位置
//                        .indicator(true)//是否显示指示器，默认不显示
//                        .imageLoader(new GlideImageLoader())//加载器，*必须配置，目前内置的有GlideImageLoader或PicassoImageLoader，也可以自己实现
//                        .theme(R.style.ImageViewerTheme)//设置主题风格，默认：R.style.ImageViewerTheme
//                        .orientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)//设置屏幕方向,默认：ActivityInfo.SCREEN_ORIENTATION_BEHIND
//                        .start(PhotoListActivity.this, v);
            }
        });

    }
}